package com.smarthealthcare.consultationinformation.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.smarthealthcare.common.annotation.Log;
import com.smarthealthcare.common.core.controller.BaseController;
import com.smarthealthcare.common.core.domain.AjaxResult;
import com.smarthealthcare.common.enums.BusinessType;
import com.smarthealthcare.consultationinformation.domain.Consultationinformation;
import com.smarthealthcare.consultationinformation.service.IConsultationinformationService;
import com.smarthealthcare.common.utils.poi.ExcelUtil;
import com.smarthealthcare.common.core.page.TableDataInfo;

/**
 * 检查信息Controller
 * 
 * @author litangwang
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/treatment/consultationinformation")
public class ConsultationinformationController extends BaseController
{
    @Autowired
    private IConsultationinformationService consultationinformationService;

    /**
     * 查询检查信息列表
     */
    @PreAuthorize("@ss.hasPermi('treatment:consultationinformation:list')")
    @GetMapping("/list")
    public TableDataInfo list(Consultationinformation consultationinformation)
    {
//        startPage();
        List<Consultationinformation> list = consultationinformationService.selectConsultationinformationList(consultationinformation);
        return getDataTable(list);
    }

    /**
     * 导出检查信息列表
     */
    @PreAuthorize("@ss.hasPermi('treatment:consultationinformation:export')")
    @Log(title = "检查信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Consultationinformation consultationinformation)
    {
        List<Consultationinformation> list = consultationinformationService.selectConsultationinformationList(consultationinformation);
        ExcelUtil<Consultationinformation> util = new ExcelUtil<Consultationinformation>(Consultationinformation.class);
        util.exportExcel(response, list, "检查信息数据");
    }

    /**
     * 获取检查信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('treatment:consultationinformation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(consultationinformationService.selectConsultationinformationById(id));
    }

    /**
     * 新增检查信息
     */
    @PreAuthorize("@ss.hasPermi('treatment:consultationinformation:add')")
    @Log(title = "检查信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Consultationinformation consultationinformation)
    {
        return toAjax(consultationinformationService.insertConsultationinformation(consultationinformation));
    }

    /**
     * 修改检查信息
     */
    @PreAuthorize("@ss.hasPermi('treatment:consultationinformation:edit')")
    @Log(title = "检查信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Consultationinformation consultationinformation)
    {
        return toAjax(consultationinformationService.updateConsultationinformation(consultationinformation));
    }

    /**
     * 删除检查信息
     */
    @PreAuthorize("@ss.hasPermi('treatment:consultationinformation:remove')")
    @Log(title = "检查信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(consultationinformationService.deleteConsultationinformationByIds(ids));
    }

    /**
     * 根据registerId查询检查信息
     * @author myf
     * @date 2024/11/25 19:24
     * @param registerId
     * @return com.smarthealthcare.common.core.domain.AjaxResult
     */
    @PreAuthorize("@ss.hasPermi('treatment:consultationinformation:query')")
    @GetMapping("/aa/{registerId}")
    public AjaxResult findConsultationinformationByRegisterId(@PathVariable("registerId") Long registerId)
    {
        System.out.println(consultationinformationService.findConsultationinformationByRegisterId(registerId));
        return success(consultationinformationService.findConsultationinformationByRegisterId(registerId));
    }
    
}
